// exceptions.cpp: implementation of the file_not_found class.
//
//////////////////////////////////////////////////////////////////////

#include "exceptions.h"
#include <string>
#include <stdarg.h>

using namespace std;
namespace sys
{
	static const char * PARSE_ERROR = "Looking for '%s' but found '%s'";
}


sys::file_not_found::file_not_found(const char * str)
: runtime_error_ex ("File could not be opened:%s",str)
{

}

sys::not_implemented::not_implemented(const char * str)
: runtime_error_ex ("Not implemented:%s",str)
{

}

sys::parse_error::parse_error(const char * strExpected ,
		                const char * strFound)
: runtime_error_ex(PARSE_ERROR, strExpected, strFound)
{
}

sys::runtime_error_ex::runtime_error_ex(const char * szFormat,...)
: runtime_error("Extended")
{
	va_list args;
	va_start(args, szFormat);
	vsprintf(m_szBuffer,szFormat,args);
	va_end (args);
}

sys::runtime_error_ex::runtime_error_ex()
: runtime_error("Extended")
{
}

void sys::runtime_error_ex::SetMessage(const char * szFormat,...) throw()
{
	va_list args;
	va_start(args, szFormat);
	vsprintf(m_szBuffer,szFormat,args);
	va_end (args);
}

const char * sys::runtime_error_ex::what() const throw()
{
	return m_szBuffer;
}
